namespace System.Xml.Serialization
{
    using System;
    using System.Text;

    [Serializable]
    public class XmlUnicodeStringSerializer<T> : XmlStringSerializer<T>
    {
        protected override byte[] Deserialize(string data)
        {
            if (!string.IsNullOrEmpty(data))
            {
                try
                {
                    return Encoding.UTF8.GetBytes(data);
                }
                catch (Exception ex)
                {
                    //PluginLog.WriteErrorSync(ex);
                }
            }
            return null;
        }

        protected override string Serialize(byte[] data)
        {
            if (data != null)
            {
                try
                {
                    return Encoding.UTF8.GetString(data);
                }
                catch (Exception ex)
                {
                    //PluginLog.WriteErrorSync(ex);
                }
            }
            return null;
        }
    }
}

